﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>千里马ERP欢迎您!!!</title>
    @*<link rel="stylesheet" href="~/css/bootstrap.css" />
        <link rel="stylesheet" href="~/css/css.css" />
        <link href="~/Content/Site.css" rel="stylesheet" />
        <script type="text/javascript" src="~/js/jquery1.9.0.min.js"></script>
        <script type="text/javascript" src="~/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="~/js/sdmenu.js"></script>
        <script type="text/javascript" src="~/js/laydate/laydate.js"></script>*@
    <link href="~/Scripts/js1/css1/bootstrap.css" rel="stylesheet" />
    <link href="~/Scripts/js1/css1/css.css" rel="stylesheet" />
    <link href="~/Scripts/js1/css1/Site.css" rel="stylesheet" />
    <script src="~/Scripts/js1/js/jquery1.9.0.min.js"></script>
    <script src="~/Scripts/js1/js/bootstrap.min.js"></script>
    <script src="~/Scripts/js1/js/sdmenu.js"></script>
    <script src="~/Scripts/js1/js/laydate/laydate.js"></script>
    @*<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="~/Scripts/js1/js/js/jquery-1.8.3.min.js"></script>
        <script src="~/Scripts/js1/js/js/raphael-min.js"></script>
        <script src="~/Scripts/js1/js/js/script.js"></script>*@
    <meta charset="utf-8">
    <title>Bootstrap Admin</title>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link href="~/Scripts/lib/bootstrap/css/bootstrap.css" rel="stylesheet" />

    <link href="~/Scripts/stylesheets/theme.css" rel="stylesheet" />
    <link href="~/Scripts/lib/font-awesome/css/font-awesome.css" rel="stylesheet" />

    <script src="~/Scripts/lib/jquery-1.7.2.min.js"></script>
    <!-- Demo page code -->

    <style type="text/css">
        #line-chart {
            height: 300px;
            width: 800px;
            margin: 0px auto;
            margin-top: 1em;
        }

        .brand {
            font-family: georgia, serif;
        }

            .brand .first {
                color: #ccc;
                font-style: italic;
            }

            .brand .second {
                color: #fff;
                font-weight: bold;
            }
    </style>

</head>
<body>
    <div class="navbar">
        <div class="navbar-inner">
            <ul class="nav pull-right">

                <li><a href="#" class="hidden-phone visible-tablet visible-desktop" role="button">Settings</a></li>
                <li id="fat-menu" class="dropdown">
                    <a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="icon-user"></i> @Session["Username"]
                        <i class="icon-caret-down"></i>
                    </a>

                    <ul class="dropdown-menu">
                        <li><a tabindex="-1" href="#">My Account</a></li>
                        <li class="divider"></li>
                        <li><a tabindex="-1" class="visible-phone" href="#">Settings</a></li>
                        <li class="divider visible-phone"></li>
                        <li><a tabindex="-1" href="/Home/Login">Logout</a></li>
                    </ul>
                </li>

            </ul>
            <a class="brand">
                <span>
                    <img src="~/1234.jpg" style="width:50px;height:50px; border-radius:25px;cursor:pointer" onclick="fun()" />
                </span><span class="first" style="font-family:华文彩云;font-size:22px">千  里  马  </span>&nbsp;&nbsp;<span class="second " style="font-size:22px;">   E R P</span>
            </a>
        </div>
    </div>
    <div class="header">
        <div class="header-right">
            <div id="modal-container-973559" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:1000px; margin-left:-500px;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3 id="myModalLabel">
                        千里马采购订单表
                    </h3>
                </div>
                <div class="modal-body">
                    供应商：@Html.DropDownList("ProviderID") 收货仓库：@Html.DropDownList("StorehouseID")单据编号：<input id="DocumentsCoding" name="DocumentsCoding" type="text" placeholder="不填写将自动生成" /><br />
                    备注：<input id="Remarks" name="Remarks" type="text" /><br />
                    @*<button type="button" onclick="selectGood()">选择商品</button><br />*@
                    <div>
                        商品名称：<input type="text" id="search" maxlength="64" /> <button type="button" onclick="fun2()">查询商品</button>
                    </div>
                    <script>
                        //function selectGood() {
                        //    $.ajax({
                        //        url: "/Procurement/ShowGoods",
                        //        type: "get",
                        //        cache: false,
                        //        success: function (data) {
                        //            $("#table2 tbody").empty();
                        //            $(data).each(function (a, c) {
                        //                var bb = '';
                        //                bb += '<tr>';
                        //                bb += '<th><input name="ck" type="checkbox" value="' + c.GoodsID + '" /></th>';
                        //                bb += '<th>' + c.GoodsCoding + '</th>';
                        //                bb += '<th>' + c.GoodsName + '</th>';
                        //                bb += '<th><input id="Goodsnum' + c.GoodsID + '" name="GoodsNum" type="text" /></th>';
                        //                bb += '<th><input id="PurchaseOrderSheetmoney' + c.GoodsID + '" name="PurchaseOrderSheetmoney" type="text" /></th>';
                        //                bb += '</tr>';
                        //                $("#table2 tbody").append(bb);
                        //            })
                        //        }
                        //    })
                        //}
                        function fun2() {
                            $.ajax({
                                type: "get",
                                url: "/Procurement/GetGoodsByGoodsName",
                                data: {
                                    GoodsName: $("#search").val()
                                },
                                success: function (data) {
                                    //$("#table2 tbody").empty();
                                    $(data).each(function (a, c) {
                                        var bb = '';
                                        bb += '<tr>';
                                        bb += '<th><input name="ck" type="checkbox" value="' + c.GoodsID + '" /></th>';
                                        bb += '<th>' + c.GoodsCoding + '</th>';
                                        bb += '<th>' + c.GoodsName + '</th>';
                                        bb += '<th><input id="Goodsnum' + c.GoodsID + '" name="GoodsNum" type="text" /></th>';
                                        bb += '<th><input id="PurchaseOrderSheetmoney' + c.GoodsID + '" name="PurchaseOrderSheetmoney" type="text" /></th>';
                                        bb += '</tr>';
                                        $("#table2 tbody").append(bb);
                                    })
                                }
                            })
                            }
                    </script>
                    <table id="table2" class="table table-hover table-bordered " style="width:1000px;text-align:center;margin:0 auto;border:2px solid #428bca;">
                        <thead>
                            <tr>
                                <th><input id="Checkbox1" type="checkbox" onclick="selectAll()" />全选</th>
                                <th>商品编码</th>
                                <th>商品名称</th>
                                <th>采购数量</th>
                                <th>采购价格</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                    <script>
                        //全选 全不选
                        function selectAll() {
                            //判断是否全选
                            if ($("#Checkbox1").attr("checked") == "checked") {
                                $("[name='ck']").attr("checked", "checked");
                            }
                            else {
                                $("[name='ck']").removeAttr("checked");
                            }
                        }
                        function addSelectItem() {
                            //商品编号
                            var selectVale = "";
                            //商品数量
                            var goodsnum = "";
                            //商品备注
                            var PurchaseOrderSheetmoney = "";
                            var emplist = $("[name = 'ck']:checked");
                            $(emplist).each(function (index, emp) {
                                ss = $(emp).val();
                                goodsnum += $("#Goodsnum" + ss + "").val() + ",";
                                PurchaseOrderSheetmoney += $("#PurchaseOrderSheetmoney" + ss + "").val() + ",";
                                if (selectVale.length > 0) {
                                    selectVale += ",";
                                }
                                selectVale += $(emp).val();
                            });
                            goodsnum = goodsnum.substr(0, goodsnum.length - 1);
                            PurchaseOrderSheetmoney = PurchaseOrderSheetmoney.substr(0, PurchaseOrderSheetmoney.length - 1);
                            $.ajax({
                                type: "get",
                                url: "/Procurement/ProcurementAdd",
                                cache: false,
                                data: {
                                    selectVale: selectVale,
                                    ProviderID: $("#ProviderID").val(),
                                    StorehouseID: $("#StorehouseID").val(),
                                    DocumentsCoding: $("#DocumentsCoding").val(),
                                    Remarks: $("#Remarks").val(),
                                    GoodsNum: goodsnum,
                                    PurchaseOrderSheetmoney: PurchaseOrderSheetmoney
                                },
                                success: function (data) {
                                    if (data == "1") {
                                        location.href = '/Procurement/Procurement_Show';
                                        alert('采购成功！！！');
                                    }
                                    else {
                                        alert('采购失败！！！');
                                    }
                                },
                                eorror: function () {
                                    alert("出错了！！！");
                                }
                            })
                        }
                    </script>
                </div>
                <div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button> <button onclick="addSelectItem()" class="btn btn-default"><span class="icon-inbox"></span>保存</button>
                </div>
            </div>
        </div>
    </div>
    @*<script>
            function Cus_Add()
            {
                $.ajax({
                    Type: "post",
                    Url: "/Custom_Info/Custom_Info_Add",
                    data: {
                        Name: $("input['name=Custom_Info_Name']").val(),
                        Nick: $("input['name=Custom_Info_Nick']")
                    }
                })
            }
        </script>*@
    <!-- 顶部 -->

    <div id="middle">
        <div class="left">
            <div class="sidebar-nav">
                <a href="#dashboard-menu" class="nav-header" data-toggle="collapse"><i class="icon-dashboard"></i>基础信息</a>
                <ul id="dashboard-menu" class="nav nav-list collapse in">
                    <li><a href="/Client/Client_Show">客户管理</a></li>
                    <li><a href="/Provider/Provider_show">快递公司</a></li>
                    <li><a href="/Experss/Experss_Show">供应商</a></li>
                    <li><a href="/Express_mate/Exress_mate_Show">快递匹配</a></li>
                    <li><a href="/calendar/calendar_Show">仓库</a></li>
                    <li><a href="/Inventory/ShowInventory">库存管理</a></li>
                </ul>

                <a href="#accounts-menu" class="nav-header" data-toggle="collapse"><i class="icon-briefcase"></i>商品管理</a>
                <ul id="accounts-menu" class="nav nav-list collapse">
                    <li><a href="/Blurb/Blurb_Show">商品信息</a></li>
                    @*<li><a href="/Brand/Brand_Show">商品品牌</a></li>
                        <li><a href="/Category/Category_Show">商品分类</a></li>
                        <li><a href="/Report/Report_Show">商品报表</a></li>*@
                </ul>

                <a href="#error-menu" class="nav-header collapsed" data-toggle="collapse"><i class="icon-exclamation-sign"></i>订单管理@*<i class="icon-chevron-up"></i>*@</a>
                <ul id="error-menu" class="nav nav-list collapse">
                    <li><a href="/Order/Order_Show">新增订单</a></li>
                    <li><a href="/Order/Order_details">订单信息</a></li><li><a href="/Order/SelShow">订单报表</a></li>
                </ul>

                <a href="#legal-menu" class="nav-header" data-toggle="collapse"><i class="icon-legal"></i>采购管理</a>
                <ul id="legal-menu" class="nav nav-list collapse">
                    <li><a href="/Procurement/Procurement_Show">采购订单</a></li>
                    <li><a href="/Stock/Stock_Show">入库信息</a></li>
                </ul>

                <a href="#leaf-menu" class="nav-header" data-toggle="collapse"><i class="icon-leaf"></i>系统设置</a>
                <ul id="leaf-menu" class="nav nav-list collapse">
                    <li><a href="/Shop/Shop_Show">店铺管理</a></li>
                    <li><a href="/Account/Account_Show">账号管理</a></li>
                </ul>
                @*<a href="help.html" class="nav-header"><i class="icon-question-sign"></i>店铺管理</a>
                    <a href="faq.html" class="nav-header"><i class="icon-comment"></i>账号管理</a>*@
            </div>

        </div>
        <div class="Switch"></div>
        <script type="text/javascript">
            $(document).ready(function (e) {
                $(".Switch").click(function () {
                    $(".left").toggle();

                });
            });
        </script>

        <div class="right" id="mainFrame">

            <div class="right_cont">
                <ul class="breadcrumb">
                    当前位置：
                    <a href="/Home/Index">首页</a>
                    <span class="divider">/</span>
                    采购订单
                </ul>
                <div class="title_right"><strong>千里马采购订单</strong></div>
                <div style="width:100%; margin:auto">
                    <div>
                        <table>
                            <tr>
                                <td>单据编码:</td>
                                <td><input id="DocumentsCoding" name="DocumentsCoding" type="text" /></td>
                                <td><button type="button" class="btn btn-default" onclick="StockOrderSearch()"><span class="icon-search"></span>查询 </button></td>
                                <td><button id="modal-973559" href="#modal-container-973559" role="button" type="button" class="btn btn-default" data-toggle="modal"><span class="icon-plus"></span>新增</button></td>
                            </tr>
                        </table>
                    </div>
                    <div style="margin-top:20px;">
                        <table id="table1" class="table  table-hover table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th>单据编码</th>
                                    <th>采购时间</th>
                                    <th>供应商名称</th>
                                    <th>仓库名称</th>
                                    <th>备注</th>
                                    <th>最后修改时间</th>
                                    <th colspan="4">操作</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                        <script>
                            $(document).ready(function () {
                                $.ajax({
                                    url: "/Procurement/ShowStockOrder",
                                    type: "get",
                                    cache:false,
                                    success: function (data) {
                                        $("#table1 tbody").empty();
                                        $(data).each(function (index, item) {
                                            var aa = '';
                                            aa += '<tr>';
                                            aa += '<th>' + item.DocumentsCoding + '</th>';
                                            aa += '<th>' + item.StockOrderTime + '</th>';
                                            aa += '<th>' + item.ProviderName + '</th>';
                                            aa += '<th>' + item.StorehouseName + '</th>';
                                            aa += '<th>' + item.Remarks + '</th>';
                                            aa += '<th>' + item.LastModified + '</th>';
                                            aa += '<th><a href="/Procurement/DelStockOrderInfoAndPurcurementByStockOrderID/' + item.StockOrderID + '" onclick="return confirm(\'真的要删除吗？\')" >删除</a></th>';
                                            aa += '<th><button id="modal-973560" href="#modal-container-973560" role="button" type="button" class="btn btn-default" data-toggle="modal" onclick="GetPur(' + item.StockOrderID + ')">详情</button></th>';
                                            aa += '</tr>';
                                            $("#table1 tbody").append(aa);
                                        })
                                    }
                                })
                            })
                            function StockOrderSearch() {
                                $.ajax({
                                    url: "/Procurement/SearchStockOrder",
                                    type: "get",
                                    data: {
                                        DocumentsCoding: $("#DocumentsCoding").val()
                                    },
                                    success: function (data) {
                                        $("#table1 tbody").empty();
                                        $(data).each(function (index, item) {
                                            var aa = '';
                                            aa += '<tr>';
                                            aa += '<th>' + item.DocumentsCoding + '</th>';
                                            aa += '<th>' + item.StockOrderTime + '</th>';
                                            aa += '<th>' + item.ProviderName + '</th>';
                                            aa += '<th>' + item.StorehouseName + '</th>';
                                            aa += '<th>' + item.Remarks + '</th>';
                                            aa += '<th>' + item.LastModified + '</th>';
                                            aa += '<th><a href="/Procurement/DelStockOrderInfoAndPurcurementByStockOrderID/' + item.StockOrderID + '" onclick="return confirm(\'真的要删除吗？\')" >删除</a></th>';
                                            aa += '<th><button id="modal-973560" href="#modal-container-973560" role="button" type="button" class="btn btn-default" data-toggle="modal" onclick="GetPur(' + item.StockOrderID + ')">详情</button></th>';
                                            aa += '</tr>';
                                            $("#table1 tbody").append(aa);
                                        })
                                    }
                                })
                            }
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @*千里马采购订单表详情*@
    <div id="modal-container-973560" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:1000px; margin-left:-500px;">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">
                千里马采购订单表详情
            </h3>
        </div>
        <div class="modal-body">
            <table id="table4" class="table  table-hover table-bordered table-striped">
                <thead>
                    <tr>
                        <th>单据编码</th>
                        <th>采购时间</th>
                        <th>供应商名称</th>
                        <th>仓库名称</th>
                        <th>备注</th>
                        <th>最后修改时间</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
            <script>
                function GetPur(StockOrderID) {
                    $.ajax({
                        url: "/Procurement/GetProcurementByStockOrderID",
                        type: "get",
                        cache: false,
                        data: {
                            id: StockOrderID
                        },
                        success: function (data) {
                            $("#table3 tbody").empty();
                            $(data).each(function (a, c) {
                                var bb = '';
                                bb += '<tr>';
                                bb += '<th><input name="firstck" type="checkbox" value="' + c.PurchaseOrderSheetID + '" checked="checked" /></th>';
                                bb += '<th>' + c.GoodsCoding + '</th>';
                                bb += '<th>' + c.GoodsName + '</th>';
                                bb += '<th>' + c.GoodsNum + '</th>';
                                bb += '<th>' + c.PurchaseOrderSheetmoney + '</th>';
                                bb += '<th><input id="PurchaseOrderSheetNum'+c.PurchaseOrderSheetID+'" name="PurchaseOrderSheetNum" type="text" /></th>';
                                bb += '</tr>';
                                $("#table3 tbody").append(bb);
                            })
                        }
                    })
                    $.ajax({
                        url: "/Procurement/GetStockOrderByStockOrderID",
                        type: "get",
                        cache: false,
                        data: {
                            id: StockOrderID
                        },
                        success: function (data) {
                            $("#table4 tbody").empty();
                            $(data).each(function (index, item) {
                                var aa = '';
                                aa += '<tr>';
                                aa += '<th>' + item.DocumentsCoding + '</th>';
                                aa += '<th>' + item.StockOrderTime + '</th>';
                                aa += '<th>' + item.ProviderName + '</th>';
                                aa += '<th>' + item.StorehouseName + '</th>';
                                aa += '<th>' + item.Remarks + '</th>';
                                aa += '<th>' + item.LastModified + '</th>';
                                aa += '</tr>';
                                $("#table4 tbody").append(aa);
                            })
                        }
                    })
                }
            </script>
            <table id="table3" class="table table-hover table-bordered " style="width:1000px;text-align:center;margin:0 auto;border:2px solid #428bca;">
                <thead>
                    <tr>
                        <th><input id="checkboxfirstcheck" type="checkbox" onclick="selectcheck()" />全选</th>
                        <th>采购商品编码</th>
                        <th>采购商品名称</th>
                        <th>采购数量</th>
                        <th>采购价格</th>   
                        <th>到货数量</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button> <button type="button" class="btn btn-default" onclick="FristCheck()"><span class="icon-inbox"></span>审核入库</button>
        </div>
    </div>
    <script>
        function selectcheck() {
            //判断是否全选
            if ($("#checkboxfirstcheck").attr("checked") == "checked") {
                $("[name='firstck']").attr("checked", "checked");
            }
            else {
                $("[name='firstck']").removeAttr("checked");
            }
        }
        function FristCheck() {
            //采购编号
            var selectVale = "";
            //采购数量
            var PurchaseOrderSheetNum = "";
            var emplist = $("[name = 'firstck']:checked");
            $(emplist).each(function (index, emp) {
                ss = $(emp).val();
                PurchaseOrderSheetNum += $("#PurchaseOrderSheetNum" + ss + "").val() + ",";
                if (selectVale.length > 0) {
                    selectVale += ",";
                }
                selectVale += $(emp).val();
            });
            PurchaseOrderSheetNum = PurchaseOrderSheetNum.substr(0, PurchaseOrderSheetNum.length - 1);
            $.ajax({
                url: "/Procurement/FristChecks",
                type: "post",
                cache: false,
                data: {
                    sPurchaseOrderSheetID:selectVale,
                    sPurchaseOrderSheetNum:PurchaseOrderSheetNum
                },
                success:function (data) {
                    if(data=="1"){
                        alert('审核通过');
                        location.href  = "/Procurement/Procurement_Show";
                    }
                    else
                    {
                        alert('审核失败');
                    }
                },
                error:function () {
                    alert('出错了');
                }
            })
        }
    </script>
    <!-- 底部 -->
    <div id="footer">版权所有：千里马ERP</div>



    <script>
        !function () {
            laydate.skin('molv');
            laydate({ elem: '#Calendar' });
        }();

        function fun() {
            location.href = '/Home/Index';
        }
    </script>

</body>
</html>
